<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>key和数组检测</title>
</head>
<body>
<div id="app">
  <ul>
    <li v-for="item in array" :key="item.id"><input type="checkbox">{{item.city}}</li>
  </ul>
  <button @click="add">添加</button>

</div>

<script src="../vue.global.js"></script>
<script>
  const App = {
    data(){
      return {
        array: [
          {city: '北京', id:1},
          {city: '上海', id:2},
          {city: '广州', id:3},
          {city: '深圳', id:4},
        ],
      }
    },
    methods: {
      add(){
        this.array.unshift({city: '汕头', id:5})
      }
    }
  }

  const vm = Vue.createApp(App).mount('#app');
  console.log(vm)
</script>
</body>
</html>
